
#include "packagefilter.h"

namespace ProcessRouter {

PackageEvent::PackageEvent(CMessage message)
    : m_message(message)
{
    if (!m_package.ParseFromString(message.content())) {
        std::cout << "Failed to parse MessagePackage " << getpid() << std::endl;
        m_package.set_name("");
    } else
        this->setType(m_package.name().c_str());
}

bool PackageFilter::dispatch(CMessage message, bool verify)
{
    PackageEvent event(message);

    /*
    if (event.package().name() != "ProcessRouter.CoreStatus") {
        std::cout << "Recevied info : " << event.package().name() << std::endl;
    }
    */
    if (event.package().name() != "")
        Rooftop::EventManager::getInstance()->dispachEvent(event);
}

}

